import entity.Message;
import processor.Client;

import java.util.Random;
import java.util.Scanner;

/**
 * 客户端启动类
 */
public class MainClient {
    public static void main(String[] args) {
        // 模拟，随机生成用户名
        String UserId = "usr_" + (new Random()).nextInt(100);
        Scanner scanner = new Scanner(System.in);
        Client client = new Client();

        // 模拟，随机生成聊天室（1 - 3）
        Random randomChatRoom = new Random();
        int sessionId = randomChatRoom.nextInt(3);

        while (true) {
            String inputLine = scanner.nextLine();
            System.out.println("--" + inputLine);

            // 随机忘3个聊天室的任意一个发消息

            Message msg = new Message(sessionId + "", UserId, inputLine);
            client.sendMessage(msg);
        }
    }
}
